﻿/*
在这里我觉得需要回顾一下Page的加载顺序。

   1. Page的构造函数
   2. protected void Page_PreInit(object sender, EventArgs e)
   3. protected void Page_Init(object sender, EventArgs e)
   4. protected void Page_InitCompleted(object send, EventArgs e)
   5. protected void Page_PreLoad(object sender, EventArgs e)
   6. protected void Page_Load(object sender, EventArgs e)
   7. 处理完Page_Load事件，如果有提交事件就开始处理提交事件，在处理完提交事件之后在处理剩下的Page事件
   8. protected void Page_LoadComplete(object sender, EventArgs e)
   9. protected void Page_PreRender(object sender, EventArgs e)
10. protected void Page_PreRenderComplete(object sender, EventArgs e)
11. protected void Page_SaveStateComplete(object sender, EventArgs e)
用户类型,0系统用户，1商户，2客户,3推广员，4代理商
*/


using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

namespace msBsc.Cls
{ 

    public class mbPage : Page
    {
        public msBsc.WebUi.Code.mQtHtmlGet omQtHtmlGet = new WebUi.Code.mQtHtmlGet();
        public string GetRadomString()
        {
            long i = 1;
            foreach (byte b in Guid.NewGuid().ToByteArray())
            {
                i *= ((int)b + 1);
            }
            return string.Format("{0:x}", i - DateTime.Now.Ticks);
            //Random rd = new Random(unchecked((int)DateTime.Now.Ticks)); 
            //return GenerateStrId().ToString(); 
        }

        /// <summary>
        /// 获取URL参数
        /// </summary>
        /// <param name="ParamName"></param>
        /// <returns></returns>
        public string GetFormParam(string ParamName)
        {
            if (string.IsNullOrEmpty(Request.Params[ParamName]))
                return string.Empty;
            else
                return Request.Params[ParamName];
        }

        public string GetParamValue(string strCallBackParam, string strParam)
        {
            if (string.IsNullOrEmpty(strCallBackParam))
                return string.Empty;
            else
            {
                string[] arrParam = strCallBackParam.Split(new char[] { ';' });
                for (int i = 0; i < arrParam.Length; i++)
                {
                    string[] arrValue = arrParam[i].Split(new char[] { '|' });
                    if (arrValue.Length > 0)
                    {
                        if (arrValue[0].Trim().ToUpper() == strParam.Trim().ToUpper())
                        {
                            if (arrValue.Length > 1)
                                return arrValue[1];
                            else
                                return string.Empty;
                        }
                    }
                }
            }
            return string.Empty;
        }

        private string _strExecJs = "";


        //protected override void Render(HtmlTextWriter writer)
        //{
        //    using (StringWriter sw = new StringWriter())
        //    {
        //        using (HtmlTextWriter op = new HtmlTextWriter(sw))
        //        {
        //            base.Render(op);
        //            //
        //            StringBuilder strHtml = sw.GetStringBuilder();

        //            strHtml = strHtml.Replace("[dirDumm]/", httpUrlBase); 
        //            strHtml.Append("<script type='text/javascript'>" + GetExecJs() + "</script>");
        //            writer.Write(strHtml);
        //        }
        //    }
        //}

         

        protected override void OnPreRenderComplete(EventArgs e)
        {
            base.OnPreRenderComplete(e);
        }


        private msBsc.AppLogic.Cfg.SynDictionary oSessiontem = new msBsc.AppLogic.Cfg.SynDictionary(false);
        private System.Collections.Generic.Dictionary<string, char> oSessiontemKeytem = new System.Collections.Generic.Dictionary<string, char>();
        /// <summary>
        /// 获取值后，如果对值做了更改，必须调用SetSession,重新保存值
        /// </summary>
        /// <param name="strpKey"></param>
        /// <param name="strpSessionType">0数据分页，1一次保存，2二次保存，3分布式缓存</param>
        /// <returns></returns>
        public object GetSession(string strpKey, string strpSessionType)
        {
            if (strpSessionType == "0" || strpSessionType == "1")
            {
                return null;
            }
            if (oSessiontem.ContainsKey(strpKey))
            {
                return oSessiontem[strpKey];
            }
            if (HttpContext.Current != null && HttpContext.Current.Session != null)
            {
                object oRettm1 = HttpContext.Current.Session[strpKey];
                //if (oRettm1 != null && oRettm1.GetType() == typeof(string))
                //{
                //    string stem2 = (string)oRettm1;
                    //if (stem2.StartsWith("$Mc$"))
                    //{
                    //    object otem1=msBsc.SvRef.MemcachedClientRef.getObjectFromCached(stem2, "$Mc$");
                    //    if(otem1!=null &&otem1.GetType()==typeof(System.Data.DataSet))
                    //    {
                    //        DataSet dstem111=((System.Data.DataSet)otem1);
                    //        using (CDbAccess DataObj = new CDbAccess())
                    //        {
                    //            DataObj.BoundColChag(dstem111, false);
                    //        }
                    //    }

                    //    oSessiontem[strpKey] = otem1;
                    //    oSessiontemKeytem[strpKey] = strpSessionType[0];
                    //    return otem1;
                    //}
                    //else
                    //{
                        //oSessiontem[strpKey] = stem2;
                        //oSessiontemKeytem[strpKey] = strpSessionType[0];
                        //return stem2;
                    //}
                //}
                //else
                //{
                    oSessiontem[strpKey] = oRettm1;
                    oSessiontemKeytem[strpKey] = strpSessionType[0];
                    return oRettm1;
                //}
            }
            else
            {
                oSessiontem[strpKey] = null;
                return null;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="strpKey"></param>
        /// <param name="opValue"></param>
        /// <param name="strpSessionType">0数据分页，1一次保存，2二次保存，3分布式缓存</param>
        /// <param name="blSaveToPagetem"></param>
        public void SetSession(string strpKey, object opValue, string strpSessionType,bool blSaveToPagetem=true)
        {
            if (strpSessionType == "0" || strpSessionType == "1")
            {
                return ;
            }

            if (blSaveToPagetem)
            {
                if (opValue == null)
                {
                    oSessiontem.Delete(strpKey);
                }
                else
                {
                    oSessiontem[strpKey] = opValue;
                    oSessiontemKeytem[strpKey] = strpSessionType[0];
                }
            }
            if (opValue != null)
            {
            //if (opValue != null && (opValue.GetType() == typeof(System.Data.DataSet) || opValue.GetType() == typeof(System.Collections.Hashtable) || opValue.GetType() == typeof(msBsc.AppLogic.Cfg.SynDictionary)))
            //{
            //    string keytem1 = "";
            //    if (HttpContext.Current != null && HttpContext.Current.Session != null)
            //    {
            //        object oRettm1 = HttpContext.Current.Session[strpKey];
            //        if (oRettm1 != null && oRettm1.GetType() == typeof(string))
            //        {
            //            keytem1 = (string)oRettm1;
            //        }
            //    }
            //    keytem1 = msBsc.SvRef.MemcachedClientRef.setObjectToCached(keytem1, opValue, "$Mc$");
            //    if (HttpContext.Current != null && HttpContext.Current.Session != null)
            //    {
            //        if (keytem1 == string.Empty)
            //        {
                        HttpContext.Current.Session[strpKey] = opValue;
                //    }
                //    else
                //    {
                //        HttpContext.Current.Session[strpKey] = keytem1;
                //    }
                //}
            }
            else if (HttpContext.Current != null && HttpContext.Current.Session != null)
            {
                HttpContext.Current.Session[strpKey] = opValue;
                if (opValue == null)
                {
                    HttpContext.Current.Session.Remove(strpKey);
                }
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <param name="strpSessionType">0数据分页，1一次保存，2二次保存，3分布式缓存</param>
        /// <returns></returns>
        public bool SessionIsExists(string key, string strpSessionType)
        {
            if (strpSessionType == "0" || strpSessionType == "1")
            {
                return false;
            }
            return GetSession(key, strpSessionType) != null;
        }

        private string _blCloseW = "";
        //public void CloseW(bool blUpdataP)
        //{
        //    _blCloseW = "CloseActiveW(" + blUpdataP.ToString().ToLower()+ ");";
        //}
        private string _strAlertMsg = "";
        public void Alert(string strMsg)
        {
            _strAlertMsg += "\r\n" + strMsg;
        }
        public void SetContrlHtml(string strCClientId, string strHtml)
        {
            if (strCClientId == "") return;
            strHtml = msBsc.AppLogic.Cfg.HttpTools.stringToJson(strHtml);
            this.ExecJScript("$('#" + strCClientId + "').html('" + strHtml + "');");
        }
        public void SetContrlValue(string strCClientId, string strValue)
        {
            if (strCClientId == "") return;
            strValue = msBsc.AppLogic.Cfg.HttpTools.stringToJson(strValue);
            this.ExecJScript("$('#" + strCClientId + "').val('" + strValue + "');");
            //this.ExecJScript("cSetCtrlV('" + strCClientId + "','" + strValue + "');");
        }
        //public void SetContrlValue(string strCClientId, string strValue,string strNme)
        //{
        //    if (strCClientId == "") return;
        //    strValue =msBsc.AppLogic.Cfg.HttpTools.stringToJson(strValue);
        //    this.ExecJScript("cSetCtrlV('" + strCClientId + "','" + strValue + "','" + msBsc.AppLogic.Cfg.HttpTools.stringToJson(strNme) + "');");
        //}
        //public void SetContrlEnable(string strCClientId, bool blEnable)
        //{
        //    if (strCClientId == "") return;
        //    if (blEnable)
        //    {
        //        this.ExecJScript("SetBtnEnable('"+strCClientId+"');");
        //    }
        //    else
        //    {
        //        this.ExecJScript("SetBtnEnable('','" + strCClientId + "');");
        //    }
        //    //blEnable = !blEnable;
        //    //this.ExecJScript("$('#" + strCClientId + "').attr('disabled', " + blEnable.ToString().ToLower() + ");");
        //}
        //public void EnabledLinkBtn(string strBtnNme, bool blEnabled)
        //{
        //    if (strBtnNme == "") return;
        //    SetContrlEnable(strBtnNme, blEnabled);
        //    //blEnabled = !blEnabled;
        //    //this.ExecJScript("$('#" + strBtnNme + "').attr('disabled', " + blEnabled.ToString().ToLower() + ");");

        //    //this.ExecJScript("$('#" + strBtnNme + "').linkbutton({ disabled: " + (!blEnabled).ToString().ToLower() + " });");
        //}
        public void DisplayLinkBtn(string strBtnNme, bool blEnabled)
        {
            if(blEnabled)
                this.ExecJScript("$('#" + strBtnNme + "').show();");
            else
                this.ExecJScript("$('#" + strBtnNme + "').hide();");
        }

        //public bool IsInnerFw
        //{
        //    get
        //    {
        //        return this.OperatorOffice.ToUpper().StartsWith("SHMSHWYS");
        //    }
        //}

        public void ToErrPage(string strErrMsg)
        {
            this.Response.Redirect("/mp_ErrInfo.htm?msg=" + strErrMsg);
        }

        public string GetPageSelectedIds(string _strRadom)
        {
            if (_strRadom == "")
            {
                return "";
            }
            if (Session[_strRadom + "_SELECTED_IDS"] != null && (string)Session[_strRadom + "_SELECTED_IDS"] != string.Empty)
            {
                string strtem1 = (string)Session[_strRadom + "_SELECTED_IDS"];
                if (strtem1.Length <= 19 || DateTime.Parse(strtem1.Substring(0, 19)) < System.DateTime.Now)
                {
                    Session.Remove(_strRadom + "_SELECTED_IDS");
                    return "";
                }
                else
                {
                    return strtem1.Substring(19);
                }
            }
            return "";
        }

        /// <summary>
        /// 设置传递的参数，默认用R_GET传递页面随机数
        /// </summary>
        /// <param name="_strIds"></param>
        public void SetPageSelectedIds( string _strIds)
        {
            SetPageSelectedIds(sCurrPageRadom, _strIds);
        }

        /// <summary>
        /// 设置传递的参数，默认用R_GET传递页面随机数
        /// </summary>
        /// <param name="_strRadom"></param>
        /// <param name="_strIds"></param>
        public void SetPageSelectedIds(string _strRadom, string _strIds)
        {
            Session[_strRadom + "_SELECTED_IDS"] = System.DateTime.Now.AddMinutes(2).ToString("yyyy-MM-dd HH:mm:ss") + _strIds;
        } 

        public bool isAjaxLoad = false;

        //业务调用时赋值到哈希表，供前台文件调用GetPageLoadData('')
        private msBsc.AppLogic.Cfg.SynDictionary _htPageLoadRetRow = new msBsc.AppLogic.Cfg.SynDictionary(false);
        public void AddPageLoadData(DataRow dr)
        {
            msBsc.AppLogic.Cfg.HttpTools.GetHashtByRow(dr, _htPageLoadRetRow);
        }
        public void AddPageLoadData(string strColNme, string strValue)
        {
            msBsc.AppLogic.Cfg.HttpTools.GetHashtByValue(strColNme, strValue, _htPageLoadRetRow);
        }
        public string GetPageLoadData(string strColNme)
        {
            return GetHtValue(_htPageLoadRetRow, strColNme);
        }

        private msBsc.AppLogic.Cfg.SynDictionary _htPanel = new msBsc.AppLogic.Cfg.SynDictionary(false);
        private msBsc.AppLogic.Cfg.SynDictionary _htPageRetRow = new msBsc.AppLogic.Cfg.SynDictionary(false);
        private msBsc.AppLogic.Cfg.SynDictionary _htCustJSon = new msBsc.AppLogic.Cfg.SynDictionary(false);
        public void AddCustJson(string strColNme, string strValue)
        {
            msBsc.AppLogic.Cfg.HttpTools.GetHashtByValue(strColNme, strValue, _htCustJSon);
        }
        public void AddPageRetRow(string strPanelId, DataRow dr)
        {
            if (strPanelId == string.Empty || dr == null) return;
            if (strPanelId != string.Empty)
                msBsc.AppLogic.Cfg.HttpTools.GetHashtByValue(strPanelId, strPanelId, _htPanel);
            if (dr != null)
                msBsc.AppLogic.Cfg.HttpTools.GetHashtByRow(dr, _htPageRetRow);
        }

        public void AddPageRetRowCellValue(string strPanelId, string strColNme, string strValue)
        {
            if (strPanelId == string.Empty || strColNme == string.Empty) return;
            msBsc.AppLogic.Cfg.HttpTools.GetHashtByValue(strPanelId, strPanelId, _htPanel);
            msBsc.AppLogic.Cfg.HttpTools.GetHashtByValue(strColNme, strValue, _htPageRetRow);
        }
        public string GetHtValue(msBsc.AppLogic.Cfg.SynDictionary htParam, string strKey)
        {
            if (htParam == null) return "";
            if (htParam.ContainsKey(strKey))
            {
                return htParam[strKey].ToString();
            }
            return "";
        }
        private msBsc.AppLogic.Cfg.SynDictionary _htParamPostData = null;
        public msBsc.AppLogic.Cfg.SynDictionary htParamPostData
        {
            set
            {
                _htParamPostData = value;
            }
            get
            {
                return _htParamPostData;
            }
        }
        public string GetParamHtValue(string strKey)
        {
            if (strKey == "sRadom")
            {
                return sCurrPageRadom;
            }
            return GetHtValue(_htParamPostData, strKey);
        }
        private msBsc.AppLogic.Cfg.SynDictionary _htPostDataRow = null;
        public msBsc.AppLogic.Cfg.SynDictionary htPostDataRow
        {
            set
            {
                _htPostDataRow = value;
            }
            get
            {
                return _htPostDataRow;
            }
        }
        public string GetPostHtValue(string strKey)
        {
            return GetHtValue(_htPostDataRow, strKey);
        }
        public string strAction
        {
            get
            {
                return GetParamHtValue("ACTION");
            }
        }
        private string _EditMode = "";
        /// <summary>
        /// 获取或设置页面的编辑状态,关闭窗口时检查该状态，提醒保存
        /// </summary>
        public string EditMode
        {
            get
            {
                if (_EditMode == string.Empty)
                {
                    if (GetParamHtValue("sEditMode") != string.Empty)
                        _EditMode= GetParamHtValue("sEditMode");
                    else
                        _EditMode= GetParamHtValue("OEDITMODE");
                }
                return _EditMode;
            }
            set
            {
                _EditMode = value;
                this.ExecJScript("sPageEditMode='" + value + "';");
            }
        }
        public void SetPanalEditMode(string strPanaelId, string strMode)
        {
            this.ExecJScript("SetEditMode('" + strPanaelId + "','" + strMode + "');");
        }

        private DataTable _dtReturn;
        public void SetReturnDatatable(DataTable dt, string strKeyFieldNme)
        {
            this._dtReturn = dt;
            msBsc.AppLogic.Cfg.HttpTools.GetHashtByValue("strKeyFieldNme", strKeyFieldNme, _htParamPostData);
        }
        //public gtGridCRecord gtGridRet
        //{
        //    get;
        //    set;
        //}
        //private bool _gtGridRetSaveSuccess = true;
        //public bool gtGridRetSaveSuccess
        //{
        //    get
        //    {
        //        if (gtGridRetSaveException != string.Empty)
        //            _gtGridRetSaveSuccess = false;
        //        return _gtGridRetSaveSuccess;
        //    }
        //    set
        //    {
        //        _gtGridRetSaveSuccess = value;
        //    }
        //}
        //private string _gtGridRetSaveException = "";
        //public string gtGridRetSaveException
        //{
        //    get
        //    {
        //        return _gtGridRetSaveException;
        //    }
        //    set
        //    {
        //        _gtGridRetSaveException = value;
        //        if (value != string.Empty)
        //        {
        //            gtGridRetSaveSuccess = false;
        //        }
        //    }
        //}

        /// <summary>
        /// 返回值包含外层的"[{}]",为JQGRID数据时，不包括[]
        /// </summary>
        /// <returns></returns>
        public string GetJSonReturn()
        {
            string strCustJSon = msBsc.AppLogic.Cfg.HttpTools.GetjsonStr(_htCustJSon,false);
            string strRet = "";
            //if (gtGridRet!=null)
            //{
            //    if (this.gtGridRet.action == "load")// || this.gtGridRet.action == "save" 
            //    {
            //        string strSaveJson = "";
            //        if (this.gtGridRet.action == "save")
            //        {
            //            string stem11 = gtGridRetSaveSuccess.ToString().ToLower();
            //            strSaveJson = "success : " + stem11 + ",exception:\"" + msBsc.AppLogic.Cfg.HttpTools.stringToJson(gtGridRetSaveException) + "\"" + "";
            //        }
            //        string strJson = msBsc.AppLogic.Cfg.HttpTools.GetjsonStr(GetExecJScript(), _strAlertMsg, _blCloseW, strCustJSon, _htPanel, _htPageRetRow);
            //        strRet = msBsc.AppLogic.Cfg.HttpTools.GetJsonForgtGrid(_dtReturn, gtGridRet, strJson, strSaveJson); 
            //    }
            //    else if (this.gtGridRet.action == "export")
            //    {
            //        if (_dtReturn != null)
            //            msBsc.AppLogic.Cfg.HttpTools.gtExport(_dtReturn, gtGridRet);
            //    }
            //    else if (this.gtGridRet.action == "save")
            //    {
            //        string strJson = "," + msBsc.AppLogic.Cfg.HttpTools.GetjsonStr(GetExecJScript(), _strAlertMsg, _blCloseW, strCustJSon, _htPanel, _htPageRetRow);
            //        string stem11 = gtGridRetSaveSuccess.ToString().ToLower();
            //        strRet = "{success : " + stem11 + ",exception:\"" + msBsc.AppLogic.Cfg.HttpTools.stringToJson(gtGridRetSaveException) + "\"" + strJson + "}"; 
            //    }
            //   //strRet = msBsc.AppLogic.Cfg.HttpTools.GetJsonForJqgrid(_dtReturn, this.GetParamHtValue("COLNLIST1"), this.GetParamHtValue("strKeyFieldNme"), this.GetParamHtValue("strSortFieldNme"), int.Parse(this.GetParamHtValue("iCurrPageNum")), int.Parse(this.GetParamHtValue("iPageRows")), this.GetParamHtValue("strSord"));
            //}
            //else
            //{
                strRet = msBsc.AppLogic.Cfg.HttpTools.GetjsonStr(GetExecJScript(), _strAlertMsg, _blCloseW, strCustJSon, _htPanel, _htPageRetRow);
                strRet = "[{" + strRet + "}]";
            //}
            return strRet;
        }

        public string GetJSon(msBsc.AppLogic.Cfg.SynDictionary _thtParam, msBsc.AppLogic.Cfg.SynDictionary _thtPostData)
        {
            isAjaxLoad = true;
            //gtGridRetSaveSuccess = true;
            //gtGridRetSaveException = "";
            ////InitialByParam(_thtParam, _thtPostData);
            DoAction(_thtParam, _thtPostData);// 
            return GetJSon();
        }

        public virtual string GetJSon()
        {
            return GetJSonReturn();
        }

        public virtual void DoAction() //，以规范函数名，增加程序可读性
        {
            if (this.strAction == "init" || this.strAction == "telClick")
            {
                string pg_url = this.GetParamHtValue("pg_url");
                string pg_name = this.GetParamHtValue("pg_name");
                string pg_code = this.GetParamHtValue("pg_code");
                if (string.IsNullOrEmpty(pg_code))
                {
                    return;
                }

                string countryId = this.GetParamHtValue("countryId");
                string cityId = this.GetParamHtValue("cityId");
                string destionId = this.GetParamHtValue("destionId");
                string userId = msBsc.SvRef.UserInfo.Operator;
                using (msBsc.AppLogic.DataAlc.CBizCustomerViews custViews = new AppLogic.DataAlc.CBizCustomerViews())
                {
                    custViews.AddCustomerViewRecord(pg_code, pg_name, pg_url, userId, countryId, cityId, destionId);
                }
            }
        }
        //public void DoAction(msBsc.AppLogic.Cfg.SynDictionary _thtParam, msBsc.AppLogic.Cfg.SynDictionary _thtPostData) //，以规范函数名，增加程序可读性
        //{
        //    this.htParamPostData = _thtParam;
        //    this.htPostDataRow = _thtPostData;
        //    _sCurrPageRadom = this.sCurrPageRadom;
        //    DoAction();
        //}

        public virtual void InitialByParam()
        {
        }

        public virtual void PreDoAction()
        {
        }
        public void DoAction(msBsc.AppLogic.Cfg.SynDictionary _thtParam, msBsc.AppLogic.Cfg.SynDictionary _thtPostData)
        {
            this.htParamPostData = _thtParam;
            this.htPostDataRow = _thtPostData;
            _sCurrPageRadom = GetHtValue(_htParamPostData, "sRadom");  
            PreDoAction();
            DoAction();
            InitialByParam();
        }

        public StringBuilder strValueListJs
        {
            get;
            set;
        } 
        public static void BoundComboBox(System.Web.UI.WebControls.DropDownList dplX,
            DataSet ds,
            string strTextFieldName,
            string strValueFieldName,
            string strFilter,
            string strSort,
            bool blAddEmpty)
        {
            BoundComboBox(dplX, ds, strTextFieldName, strValueFieldName, strFilter, strSort, blAddEmpty, "");
        }

        public static void BoundComboBox(System.Web.UI.WebControls.DropDownList dplX,
            DataSet ds,
            string strTextFieldName,
            string strValueFieldName,
            string strFilter,
            string strSort,
            bool blAddEmpty,
            string strGroupField)
        {
            dplX.Items.Clear();
            if (blAddEmpty)
            {
                dplX.Items.Add(new ListItem("　", ""));
            }
            if (ds != null)
            {
                if (strGroupField != string.Empty)
                {
                    strSort = strSort == string.Empty ? strGroupField : strGroupField + "," + strSort;
                    strGroupField = strGroupField.Split(' ')[0] ?? strGroupField;
                }
                ds.Tables[0].DefaultView.RowFilter = strFilter;
                ds.Tables[0].DefaultView.Sort = strSort; 
                for (int i = 0; i < ds.Tables[0].DefaultView.Count; i++)
                {
                    DataRowView drv = ds.Tables[0].DefaultView[i];
                    ListItem ditem = dplX.Items.FindByValue(drv[strValueFieldName].ToString());
                    if (ditem != null && ditem.Text == drv[strTextFieldName].ToString())
                        continue;
                    //if(strGroupField!=string.Empty)
                    //{
                    //    string strGrouptxttm1 = drv[strGroupField].ToString();
                    //    if (strGrouptxt != strGrouptxttm1)
                    //    {
                    //        strGrouptxt = strGrouptxttm1;
                    //        dplX.Items.Add(new ListItem(strGrouptxttm1, strGrouptxttm1, false));
                    //    }
                    //}
                    dplX.Items.Add(new ListItem(drv[strTextFieldName].ToString(), drv[strValueFieldName].ToString()));
                }
            }
        }

        public void BoundComboBox(
            string strColName,
            DataSet ds,
            string strTextFieldName,
            string strValueFieldName,
            string strFilter,
            string strSort,
            bool blAddEmpty)
        {
            BoundComboBox(strColName, ds.Tables[0], strTextFieldName, strValueFieldName, strFilter, strSort, blAddEmpty);
        }
        public void BoundComboBox(
            string strColName,
            DataTable dtBound0,
            string strTextFieldName,
            string strValueFieldName,
            string strFilter,
            string strSort,
            bool blAddEmpty)
        {
            //{ '1': 'US', '2': 'FR', '3': 'BR' }
            //DataSet dsBoundSrc = ds.Copy();
            string data = "";

            if (dtBound0 != null)
            {
                DataTable dtBound = dtBound0.Copy();
                DataView dv;
                if (strFilter != string.Empty)
                {
                    dtBound.DefaultView.RowFilter = strFilter;
                    DataTable dt = dtBound.DefaultView.ToTable();
                    //DataRow[] arrtem = dtBound.Copy().Select(strFilter);
                    //for (int i = 0; i < arrtem.Length; i++)
                    //{
                    //    DataRow newDr = dt.NewRow();
                    //    newDr.ItemArray = arrtem[i].ItemArray;
                    //    dt.Rows.Add(newDr);
                    //}
                    if (blAddEmpty)
                    {
                        DataRow dr = dt.NewRow();
                        for (int i = 0; i < dt.Columns.Count; i++)
                        {
                            if (dt.Columns[i].DataType == typeof(global::System.DateTime))
                            {
                                dr[dt.Columns[i].ColumnName] = DBNull.Value;
                            }
                            else if (dt.Columns[i].DataType == typeof(global::System.TimeSpan))
                            {
                                dr[dt.Columns[i].ColumnName] = DBNull.Value;
                            }
                            else if (dt.Columns[i].DataType == typeof(decimal))
                            {
                                dr[dt.Columns[i].ColumnName] = -99999M;
                            }
                            else if (dt.Columns[i].DataType == typeof(int))
                            {
                                dr[dt.Columns[i].ColumnName] = -99999;
                            }
                            else if (dt.Columns[i].DataType == typeof(Int16))
                            {
                                dr[dt.Columns[i].ColumnName] = -99999;
                            }
                            else if (dt.Columns[i].DataType == typeof(bool))
                            {
                                dr[dt.Columns[i].ColumnName] = false;
                            }
                            else if (dt.Columns[i].DataType == typeof(byte))
                            {
                                dr[dt.Columns[i].ColumnName] = System.DBNull.Value;
                            }
                            else
                            {
                                dr[dt.Columns[i].ColumnName] = "";
                            }
                        }
                        dt.Rows.InsertAt(dr,0);
                    }
                    dt.AcceptChanges();


                    dt.DefaultView.Sort = strSort;
                    dv = dt.DefaultView;
                }
                else
                {
                    if (blAddEmpty)
                    {
                        DataTable dt = dtBound;
                        DataRow dr = dt.NewRow();
                        for (int i = 0; i < dt.Columns.Count; i++)
                        {
                            if (dt.Columns[i].DataType == typeof(global::System.DateTime))
                            {
                                dr[dt.Columns[i].ColumnName] = DBNull.Value;
                            }
                            else if (dt.Columns[i].DataType == typeof(global::System.TimeSpan))
                            {
                                dr[dt.Columns[i].ColumnName] = DBNull.Value;
                            }
                            else if (dt.Columns[i].DataType == typeof(decimal))
                            {
                                dr[dt.Columns[i].ColumnName] = -99999M;
                            }
                            else if (dt.Columns[i].DataType == typeof(int))
                            {
                                dr[dt.Columns[i].ColumnName] = -99999;
                            }
                            else if (dt.Columns[i].DataType == typeof(Int16))
                            {
                                dr[dt.Columns[i].ColumnName] = -99999;
                            }
                            else if (dt.Columns[i].DataType == typeof(bool))
                            {
                                dr[dt.Columns[i].ColumnName] = false;
                            }
                            else if (dt.Columns[i].DataType == typeof(byte))
                            {
                                dr[dt.Columns[i].ColumnName] = System.DBNull.Value;
                            }
                            else
                            {
                                dr[dt.Columns[i].ColumnName] = "";
                            }
                        }
                        dt.Rows.InsertAt(dr, 0);
                        //dt.Rows.Add(dr);
                    }
                    dtBound.DefaultView.Sort = strSort;
                    dv = dtBound.DefaultView;
                }


                if (strColName.StartsWith("dpl") || strColName.StartsWith("lsb"))
                {
                    for (int j = 0; j < dv.Count; j++)
                    {
                        data += "<option value=\"" + msBsc.AppLogic.Cfg.HttpTools.stringToJson(dv[j][strValueFieldName].ToString()) + "\">" + msBsc.AppLogic.Cfg.HttpTools.stringToJson(dv[j][strTextFieldName].ToString()) + "</option>";
                    }
                }
                else if (strColName.StartsWith("cmb"))
                {
                    for (int j = 0; j < dv.Count; j++)
                    {
                        if (j > 0)
                            data += ",";
                        data += "{\"" + "ID" + "\"";
                        data += ":\"" + msBsc.AppLogic.Cfg.HttpTools.stringToJson(dv[j][strValueFieldName].ToString()) + "\"";
                        data += ",\"" + "TXT" + "\"";
                        data += ":\"" + msBsc.AppLogic.Cfg.HttpTools.stringToJson(dv[j][strTextFieldName].ToString()) + "\"}";
                    }
                }
                else
                {
                    for (int j = 0; j < dv.Count; j++)
                    {
                        if (j > 0)
                            data += ",";
                        data += "\"" + msBsc.AppLogic.Cfg.HttpTools.stringToJson(dv[j][strValueFieldName].ToString()) + "\"";
                        data += ":\"" + msBsc.AppLogic.Cfg.HttpTools.stringToJson(dv[j][strTextFieldName].ToString()) + "\"";
                    }
                }
            }
            if (strColName.StartsWith("dpl") || strColName.StartsWith("lsb"))
            {
                this.ExecJScript("$(\"#"+strColName+"\").empty();");
                if(data!=string.Empty) this.ExecJScript("$(\"" + data.Replace("\"","\\\"") + "\").appendTo($(\"#" + strColName + "\"));");
            }
            else if (strColName.StartsWith("cmb"))
            {
                this.ExecJScript( @"var data" + strColName + @"=[" + data + @"];$(""#" + strColName + @""").combobox({data:data" + strColName + @",valueField: ""ID"",textField: ""TXT"",panelHeight: ""auto""});");
            }
            else
            {
                if (strValueListJs == null)
                    strValueListJs = new StringBuilder();
                strValueListJs .Append( @"var clop" + strColName + @"={" + data + @"};function clrd" + strColName + @"(value,record,columnObj,grid,colNo,rowNo) {var options=clop" + strColName + @";var ret=options[value];if(ret== null){ret = value;}return ret;};");
            }
        }

        //public void DownLoadFile(string strFile)
        //{
        //    DownLoadFile(strFile, "");
        //}
        //public void DownLoadFile(string strFile,string strFsnme)
        //{
        //    if (File.Exists(strFile))
        //    {
        //        ExecJScript("downfbyvp('" + Microsoft.JScript.GlobalObject.encodeURIComponent(strFile) + "','','" + Microsoft.JScript.GlobalObject.encodeURIComponent(strFsnme) + "');"); 
        //    }
        //    else if (File.Exists(msBsc.AppLogic.Cfg.SystemFileDir.FileDir.strTemXmlFileDir+ strFile))
        //    {
        //        ExecJScript("downfbyvp('" + Microsoft.JScript.GlobalObject.encodeURIComponent(strFile) + "','','" + Microsoft.JScript.GlobalObject.encodeURIComponent(strFsnme) + "');"); 
        //    }
        //    else if (File.Exists(HttpContext.Current.Server.MapPath(msBsc.AppLogic.Cfg.SystemFileDir.FileDir.UrlBase + strFile)))
        //    {
        //        ExecJScript("downfbyvp('" + Microsoft.JScript.GlobalObject.encodeURIComponent(strFile) + "','','" + Microsoft.JScript.GlobalObject.encodeURIComponent(strFsnme) + "');"); 
        //    } 
        //}

        public void ExecJScript(string strJScript)
        {
            strJScript = "\r\n" + strJScript;
            _strExecJs += strJScript;
        }
        public virtual string GetExecJScript()
        { 
            //if (_blCloseW!=string.Empty)
            //{
            //    _strExecJs = _strExecJs + "\r\n" + _blCloseW;
            //}
//            string sJSScript = @"<script type='text/javascript'> 
//" + _strExecJs + @"; 
//</script>";
            return _strExecJs;
        }

        /*********************************************************************************************************************************/

        //public bool InitSoftInfo()
        //{
        //    msBsc.AppLogic.Cfg.SysInfo oSysInfo = new msBsc.AppLogic.Cfg.SysInfo();
        //    Epm.AppLogic.Framework.ApplicationInfo.SystemType = Epm.AppLogic.Framework.ApplicationInfo.ttSystemType.WebForm;
        //    Epm.AppLogic.Framework.FrameworkSysInfo.SoftVersionBit = oSysInfo.SoftVersionBit;
        //    Epm.AppLogic.Framework.FrameworkSysInfo.SoftVersions = oSysInfo.SoftVersions;
        //    Epm.AppLogic.Framework.FrameworkSysInfo.strPrjCode = oSysInfo.strPrjCode;
        //    Epm.AppLogic.Framework.FrameworkSysInfo.strPrjNme = oSysInfo.strPrjNme; 
        //    return true;
        //}

        private string _sCurrPageRadom = "";
        /// <summary>
        /// 当前页随机数标识
        /// </summary>
        public string sCurrPageRadom
        {
            get
            {
                if (string.IsNullOrEmpty(_sCurrPageRadom))
                {
                    _sCurrPageRadom = GetRadomString();
                    //if (this.Form != null)
                    //{
                    //    System.Web.UI.Control ddd = this.Form.FindControl("sRadom");
                    //    if (ddd != null)
                    //    {
                    //        System.Web.UI.WebControls.HiddenField sRadom = (System.Web.UI.WebControls.HiddenField)ddd;
                    //        _sCurrPageRadom = sRadom.Value;
                    //    }
                    //}
                    //return string.Empty;
                }
                return _sCurrPageRadom;
            }
        }

        //public DataSet DataConst
        //{
        //    get
        //    {
        //        return msBsc.SvRef.ApplicationConst.Const.DataConst;
        //        //if (HttpContext.Current.Application["Cache:DataConst:"] != null)
        //        //    return ((DataSet)HttpContext.Current.Application["Cache:DataConst:"]).Copy();
        //        //else
        //        //{
        //        //    CBizBseConstantDict objConst = new CBizBseConstantDict();
        //        //    DataSet ds = objConst.SelectByType("", "1");
        //        //    HttpContext.Current.Application["Cache:DataConst:"] = ds;
        //        //    return ds;
        //        //}
        //    } 
        //}
         
         

        public string strPageUi
        {
            get
            {
                string[] aa = this.GetParamHtValue("PPAGE").Split('.');
                return aa.Length > 0 && !string.IsNullOrEmpty(aa[0]) ? aa[aa.Length - 1] : this.GetType().BaseType.Name;
            }
        }

        //public DataSet GetAllowPageRightDataByUsr()
        //{
        //    //string strPUrl = HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath;
        //    //if (strPUrl.StartsWith("~/"))
        //    //{
        //    //    strPUrl = strPUrl.Substring(2, strPUrl.Length - 2);
        //    //}
        //    //strPUrl = this.GetType().Name;
        //    msBsc.AppLogic.Bse.CBizSysUser objSysUser = new msBsc.AppLogic.Bse.CBizSysUser();
        //    DataSet ds = objSysUser.SelectPageAllowRight(strPageUi);
        //    return ds;
        //}

        //public string GetAllowPageRightByUsr()
        //{
        //    DataSet ds = GetAllowPageRightDataByUsr();
        //    return msBsc.AppLogic.Cfg.HttpTools.GetJsonByTable(ds.Tables[0], "", 1000, "");
        //}



        //public void AllowExecAction(string strAction)
        //{
        //    string strPUrl = HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath;
        //    if (strPUrl.StartsWith("~/"))
        //    {
        //        strPUrl = strPUrl.Substring(2, strPUrl.Length - 2);
        //    }
        //    //string strPage = Request.Path.Substring(Request.Path.LastIndexOf("/") + 1);
        //    CBizSysUser objSysUser = new CBizSysUser();
        //    if (!objSysUser.AllowAccessRight(this.Operator, strPUrl, strAction))
        //        throw new Exception("NO GRANT，对不起，你没有操作的权限！");
        //}

        //public bool GetAllowExecAction(string strAction)
        //{
        //    string strPUrl = HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath;
        //    if (strPUrl.StartsWith("~/"))
        //    {
        //        strPUrl = strPUrl.Substring(2, strPUrl.Length - 2);
        //    }
        //    //string strPage = Request.Path.Substring(Request.Path.LastIndexOf("/") + 1);
        //    CBizSysUser objSysUser = new CBizSysUser();
        //    return objSysUser.AllowAccessRight(this.Operator, strPUrl, strAction);
        //}
          
        //public string GetAllowPageRightByUsr()
        //{
        //    string strPUrl = HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath;
        //    if (strPUrl.StartsWith("~/"))
        //    {
        //        strPUrl = strPUrl.Substring(2, strPUrl.Length - 2);
        //    }
        //    CDbAccess DataObj = new CDbAccess();
        //    CDbParmCollection parmCollection = new CDbParmCollection();
        //    parmCollection.Add(new CDbParm("strPUrl", ParameterDirection.Input, EDbType.String, 500, strPUrl));
        //    parmCollection.Add(new CDbParm("strUser", ParameterDirection.Input, EDbType.String, 20, Epm.AppLogic.Framework.ApplicationInfo.Operator));

        //    DataSet ds = DataObj.QueryBySP("SYS_GET_ALLOW_PAGE_RIGHT_BY_USR", parmCollection);
        //    return msBsc.AppLogic.Cfg.HttpTools.GetJsonByTable(ds.Tables[0], "", 1000, "");
        //}

        //public BPage()
        //{
        //    //InitSoftInfo();
        //}

        public override void Dispose()
        {
            if (this.oSessiontem != null)
            {
                try
                {
                    //if (this.gtGridRet != null && this.gtGridRet.action == "save" || this.strAction.ToUpper().Contains("SAVE"))
                    //{
                        string[] arrtem11 = this.oSessiontem.Keys;
                        for (int i = arrtem11.Length - 1; i >= 0; i--)
                        {
                            if (this.oSessiontem[arrtem11[i]] == null)
                            {
                                continue;
                            }
                            if (oSessiontemKeytem[arrtem11[i]].ToString() == "2")
                            {
                                SetSession(arrtem11[i], this.oSessiontem[arrtem11[i]], oSessiontemKeytem[arrtem11[i]].ToString(), false);
                            }
                            this.oSessiontem[arrtem11[i]] = null;
                        }
                    //}
                }
                catch (Exception err)
                {
                    msBsc.AppLogic.Cfg.ApplicationLog.WriteFile(err);
                }
                this.oSessiontem.Dispose();
            }
            if (this._htCustJSon != null)
            {
                this._htCustJSon.Dispose();
            }
            if (this._htPageLoadRetRow != null)
            {
                this._htPageLoadRetRow.Dispose();
            }
            if (this._htPageRetRow != null)
            {
                this._htPageRetRow.Dispose();
            }
            if (this._htPanel != null)
            {
                this._htPanel.Dispose();
            }
            if (this._htParamPostData != null)
            {
                this._htParamPostData.Dispose();
            }
            if (this._htPostDataRow != null)
            {
                this._htPostDataRow.Dispose();
            }
            base.Dispose();
            GC.SuppressFinalize(this);//请求系统不要调用指定对象的终结器. //该方法在对象头中设置一个位，系统在调用终结器时将检查这个位
        }

        ///// <summary>
        ///// page Dispose后，回收时执行
        ///// </summary>
        //~BPage()
        //{
        //    //this.Dispose();//有可能开发人员忘记调用Dispose方法，导致资源泄漏，为了避免这种情况，在析构函数调用Dispose,确保资源被释放
        //}


        //private BseClass.AspxToHtml oAspxToHtml = new BseClass.AspxToHtml();

        //protected override void OnInit(EventArgs e)
        //{
        //    //oAspxToHtml.DoCache();
        //    base.OnInit(e);

        //    //SetLogin();//登录验证
        //    //CancelFormControlEnterKey(this.Page.Form.Controls); //取消页面文本框的enter key
        //    //this.Page.ClientScript.RegisterHiddenField("shUrlBase", msBsc.AppLogic.Cfg.SystemFileDir.FileDir.UrlBase);
        //    AddHeaderJs();//向网页头部添加js等文件 

        //    //显示帮助
        //    if (!IsPostBack)
        //    {
        //        //string strPUrl = HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath;
        //        //if (strPUrl.StartsWith("~/"))
        //        //{
        //        //    strPUrl = strPUrl.Substring(2, strPUrl.Length - 2);
        //        //}
        //        //CDbAccess DataObj = new CDbAccess();
        //        //CDbParmCollection parmCollection = new CDbParmCollection();
        //        //parmCollection.Add(new CDbParm("strPUrl", ParameterDirection.Input, EDbType.String, 500, strPUrl));
        //        //parmCollection.Add(new CDbParm("strUser", ParameterDirection.Input, EDbType.String, 20, Epm.AppLogic.Framework.ApplicationInfo.Operator));

        //        //DataSet ds = DataObj.QueryBySP("SYS_GET_PAGE_HELP_NO_BY_USR", parmCollection);
        //        //if (ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0]["HELP_NO"].ToString() != string.Empty)
        //        //{
        //        //    this.ExecJScript("ShowHelpLink('" + ds.Tables[0].Rows[0]["HELP_NO"].ToString()+"');");
        //        //}
        //    }
        //}

        //protected override void OnLoad(EventArgs e)
        //{
            
        //    base.OnLoad(e);

        //    if (strValueListJs != null && strValueListJs.ToString()!=string.Empty)
        //    {
        //        //string strtem1 = strValueListJs.ToString();
        //        Literal litUrl = new Literal();
        //        litUrl.Text = "<script type='text/javascript'>" + strValueListJs.ToString() + "</script>";
        //        Header.Controls.AddAt(1, litUrl);
        //    }
        //    if (!IsPostBack)
        //    {
        //        //Literal litUrl = new Literal();
        //        //litUrl.Text = "<script type='text/javascript'>" + GetExecJs() + "</script>";
        //        //Header.Controls.Add(  litUrl); 
        //    }
        //}
 
        #region 日志处理

        /// <summary>
        /// 出错处理:写日志,导航到公共出错页面
        /// </summary>
        /// <param name="e"></param>
        protected override void OnError(EventArgs e)
        {
            base.OnError(e);
            Exception ex = this.Server.GetLastError();
            //string strMsg = ex.Message+"</br>详细错误信息，请查看日志！";
            msBsc.AppLogic.Cfg.ApplicationLog.WriteFile(ex);
             
            string strHtmltem1 = GetErrHtml(ex);
            this.Server.ClearError();
            if (!IsCallback)
            {
                Response.Clear();
                Response.Write(strHtmltem1);
                Response.End();
            }
            //Response.Write(error);
            //this.Response.Redirect("~/wfError.aspx");
        }

        private string GetErrHtml(Exception ex)
        {
            string strHtmltem1 = "";
            strHtmltem1 += "<!DOCTYPE HTML><html lang=\"en-US\"><head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"><meta charset=\"UTF-8\"><title>CloudFlare | Error</title><link rel=\"stylesheet\" media=\"screen\" href=\"" + httpUrlBase + "styles/error.css\" />";
            strHtmltem1 += "<script type=\"text/javascript\"> ";
            strHtmltem1 += "document.cookie = 'cf_use_ob=0; path=/';";
            //strHtmltem1 += "window.onload = function() {";
            //strHtmltem1 += "    var anchor = document.getElementById('Contact');";
            //strHtmltem1 += "    anchor.href = anchor.href + \"&err_url=\" + escape(window.location.href);";
            //strHtmltem1 += "};";
            strHtmltem1 += "</script></head><body><ul id=\"Alerts\"><li class=\"alert\"><img src=\"" + httpUrlBase + "styles/alert.gif\" alert=\"Error!\" /><h1>" + ex.Message + "</h1>  <!-- Error #2001: origin_502_ob0 -->";
            strHtmltem1 += "<p>" + ex.StackTrace + "</p>";
            //strHtmltem1 += "<p>If you are the site owner, review the following <a href=\"http://www.cloudflare.com/wiki/I_keep_seeing_%22My_Site_is_Offline%22\" target=\"_blank\">resource to help</a> resolve the issue.</p>";
            strHtmltem1 += "<a class=\"corner\" href=\"#\" target=\"_blank\"></a><div class=\"clear\"></div></li></ul><ul id=\"Footer\"><li class=\"last\"><a href=\"#\">&copy; 2011 Ms-Fws, Inc.</a></li></ul></body></html>";

            return strHtmltem1;
        }

        ///// <summary>
        ///// 处理异常，用来将主要异常信息写入文本日志
        ///// </summary>
        ///// <param name="ex"></param>
        ///// <returns></returns>
        //private string DealException(Exception ex)
        //{
        //    this.Application["StackTrace"] = ex.StackTrace;
        //    this.Application["MessageError"] = ex.Message;
        //    this.Application["SourceError"] = ex.Source;
        //    this.Application["TargetSite"] = ex.TargetSite.ToString();
        //    string error = string.Format("URl：{0}\n引发异常的方法：{1}\n错误信息：{2}\n错误堆栈：{3}\n",
        //        this.Request.RawUrl, ex.TargetSite, ex.Message, ex.StackTrace);
        //    return error;
        //}

        #endregion

        #region 网页头添加通用统一js文件
        //public bool blAddGtJs
        //{
        //    get;
        //    set;
        //}
        //public bool blAddQtJs
        //{
        //    get;
        //    set;
        //}
        //public bool blAddHtJs
        //{
        //    get;
        //    set;
        //}
        //public bool blAddAuthCook
        //{
        //    get;
        //    set;
        //}
        ////public bool blNotAddJs
        ////{
        ////    get;
        ////    set;
        ////}
        //public bool blIncludValidateJs
        //{
        //    get;
        //    set;
        //}

        private string GetExecJs()
        {
            //msBsc.AppLogic.Cfg.JSCompress oJSCompress = new AppLogic.Cfg.JSCompress();
            string strCustJSon = msBsc.AppLogic.Cfg.HttpTools.GetjsonStr(_htCustJSon, false);

            string strRet = msBsc.AppLogic.Cfg.HttpTools.GetjsonStr(GetExecJScript(), _strAlertMsg, _blCloseW, strCustJSon, _htPanel, _htPageRetRow);
            strRet = "var strRet=[{" + strRet + "}];successajaxComm(strRet);";

//            return @" $(window).load(function() { 
//" + "eval(unescape('" + Microsoft.JScript.GlobalObject.escape(strRet) + "'));" + @"
//});";
            return "eval(unescape('" + Microsoft.JScript.GlobalObject.escape(strRet) + "'));";
        }

        /// <summary>
        /// 页面加载后执行的JS
        /// </summary>
        /// <returns></returns>
        public string getBodyAfterJs()
        {
            return "<script type='text/javascript'>" + GetExecJs() + "</script>";
        }

        public string getBodyBeforeJs()
        {
            string stemttt = "";
            //if (blAddAuthCook)
            //{
                if (this.Request.Cookies != null && this.Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName] != null)
                {
                    stemttt = this.Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName].Value;
                }
                stemttt="var cookesc='" + msBsc.AppLogic.Cfg.DesCry.encMe(stemttt, "cookesc") + "';";
            string strjstm="var shUrlBase='" + httpUrlBase + "';var pgtype='" + this.GetType().BaseType.FullName + "';var sCurrRadom='" + this.sCurrPageRadom + "';" + stemttt + "";
            if (strValueListJs != null && strValueListJs.ToString()!=string.Empty)
            {strjstm+=strValueListJs;
            }
            return "<script type='text/javascript'>"+strjstm+" </script>";
        }

        public string metacontent = "欢迎光临地接客商城";
        public string getMeta()
        {
            return @"<meta charset=""gbk""><meta name=""renderer"" content=""webkit""><meta name=""description"" content=""" + metacontent + @"""/><meta name=""viewport"" content=""width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"" /><meta http-equiv=""X-UA-Compatible"" content=""IE=Edge"">"
                +@"<link rel=""shortcut icon"" href=""/themes/mStyle1/Image/favicon.ico"" type=""image/x-icon"" />";
        }
         

        string _httpUrlBase = "";
        public string httpUrlBase
        {
            get
            {
                if (string.IsNullOrEmpty(_httpUrlBase))
                {
                    _httpUrlBase = msBsc.AppLogic.Cfg.SystemFileDir.FileDir.httpUrlBase;
                }
                return _httpUrlBase;
            }
        }

        //public void AddHeaderJs(string strJs)
        //{
        //    if (strValueListJs == null)
        //        strValueListJs = new StringBuilder();
        //    strValueListJs.Append(strJs);
        //}
        //private void AddHeaderJs()
        //{
        //    /* 自动添加目录下的文件
        //    string jsPath = "~/js/";
        //    string filePath = Server.MapPath(jsPath);
        //    Literal lit = new Literal();
        //    StringBuilder sb = new StringBuilder();

        //    if (!Directory.Exists(filePath))
        //        throw new Exception("路径不存在");
        //    List<string> listJs = new List<string>();
        //    foreach (var item in Directory.GetFiles(filePath, "*.js", SearchOption.TopDirectoryOnly))
        //    {
        //        listJs.Add(Path.GetFileName(item));
        //    }

        //    foreach (var jsName in listJs)
        //    {
        //        sb.Append(ScriptInclude(jsPath + jsName));
        //    }
        //     * */


        //    string stemttt = "";
        //    //if (blAddAuthCook)
        //    //{
        //        if (this.Request.Cookies != null && this.Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName] != null)
        //        {
        //            stemttt = this.Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName].Value;
        //        }
        //        stemttt="var cookesc='" + msBsc.AppLogic.Cfg.DesCry.encMe(stemttt, "cookesc") + "';";
        //    //}

        //    Literal lithc = new Literal();
        //    StringBuilder sbhc = new StringBuilder();
        //    sbhc.Append(@"<meta charset=""gbk""><meta name=""renderer"" content=""webkit""><meta name=""description"" content=""" + metacontent + @"""/><meta name=""viewport"" content=""width=device-width"" /><meta http-equiv=""X-UA-Compatible"" content=""IE=Edge"">");//<meta http-equiv=""X-UA-Compatible"" content=""IE=EmulateIE7"" /><meta http-equiv=""X-UA-Compatible"" content=""IE=7"" />
        //    sbhc.Append("\r\n<script type='text/javascript'>eval(unescape('" + Microsoft.JScript.GlobalObject.escape("var shUrlBase='" + httpUrlBase + "';var pgtype='" + this.GetType().BaseType.FullName + "';var sCurrRadom='" + this.sCurrPageRadom + "';" + stemttt + "") + "'));</script>");
        //    lithc.Text = sbhc.ToString();
        //    Header.Controls.AddAt(0, lithc);



        //    //if (blAddHtJs)
        //    //{
        //    //    Literal lit = new Literal();
        //    //    StringBuilder sb = new StringBuilder();
        //    //    string strInFileVpath = "";

        //    //    strInFileVpath = httpUrlBase + "??jqPlugin/js/jquery-1.8.3.min.js,jqPlugin/poshytip/jquery.poshytip.js,jqPlugin/lhgdialog/lhgdialog.js,jqPlugin/js/jQueryForm.js,jqPlugin/sigma_grid/gt_grid_all.js,jqPlugin/sigma_grid/gtBaseJs.js";
        //    //    sb.Append(ScriptInclude(strInFileVpath));
        //    //    strInFileVpath = httpUrlBase + "??themes/SysHt/jqcss.css,jqPlugin/poshytip/tip-yellow/tip-yellow.css,jqPlugin/poshytip/tip-yellowsimple/tip-yellowsimple.css,jqPlugin/sigma_grid/gt_grid.css";
        //    //    sb.Append(cssInclude(strInFileVpath));
        //    //    //sb.Append("<script type='text/javascript'>" + GetExecJs() + "</script>");
        //    //    lit.Text = sb.ToString();
        //    //    lit.ID = "fLink1";
        //    //    Header.Controls.AddAt(2, lit);
        //    //}
        //    //if (blAddHtJs)
        //    //{
        //    //    //strInFileVpath = httpUrlBase + "themes/SysHt/jqcss.css"; 
        //    //    //sb.Append(cssInclude(strInFileVpath));

        //    //    //strInFileVpath = httpUrlBase + "jqPlugin/poshytip/tip-yellow/tip-yellow.css";
        //    //    //sb.Append(cssInclude(strInFileVpath));
        //    //    //strInFileVpath = httpUrlBase + "jqPlugin/poshytip/tip-yellowsimple/tip-yellowsimple.css";
        //    //    //sb.Append(cssInclude(strInFileVpath));

        //    //    //strInFileVpath = httpUrlBase + "jqPlugin/poshytip/jquery.poshytip.js";
        //    //    //sb.Append(ScriptInclude(strInFileVpath));

        //    //    //strInFileVpath = httpUrlBase + "jqPlugin/lhgdialog/lhgdialog.js?t=self&s=chrome,facebook,aero,default"; 
        //    //    //sb.Append(ScriptInclude(strInFileVpath));

        //    //    //strInFileVpath = httpUrlBase + "jqPlugin/AutoComplete/jquery.autocomplete.js"; 
        //    //    //sb.Append(ScriptInclude(strInFileVpath));
        //    //    //strInFileVpath = httpUrlBase + "jqPlugin/AutoComplete/jquery.autocomplete.css"; 
        //    //    //sb.Append(cssInclude(strInFileVpath));


        //    //    //strInFileVpath = httpUrlBase + "jqPlugin/js/jQueryForm.js?R=20140623"; 
        //    //    //sb.Append(ScriptInclude(strInFileVpath));
        //    //}
        //    //else
        //    //{ 
        //    //    strInFileVpath = httpUrlBase + "jqPlugin/js/jQueryCmd.js?R=20140623";
        //    //    //if (File.Exists(Server.MapPath(strInFileVpath)))
        //    //    sb.Append(ScriptInclude(strInFileVpath));
        //    //}
        //    //if (blAddQtJs)
        //    //{ 
        //    //    //strInFileVpath = httpUrlBase + "themes/Style1/StyleQt.css";
        //    //    //sb.Append(cssInclude(strInFileVpath));
        //    //    //strInFileVpath = httpUrlBase + "themes/Style1/jsQt.js";
        //    //    //sb.Append(ScriptInclude(strInFileVpath));
        //    //}
        //    //if (blAddGtJs)
        //    //{

        //    //    //strInFileVpath = httpUrlBase + "jqPlugin/sigma_grid/gt_grid.css";
        //    //    //sb.Append(cssInclude(strInFileVpath));


        //    //    //strInFileVpath = httpUrlBase + "jqPlugin/sigma_grid/gt_grid_all.js";
        //    //    //sb.Append(ScriptInclude(strInFileVpath));
        //    //    //strInFileVpath = httpUrlBase + "jqPlugin/sigma_grid/gtBaseJs.js?R=20140606";
        //    //    //sb.Append(ScriptInclude(strInFileVpath));
        //    //}
             

        //    //lit.Text = sb.ToString();
        //    //lit.ID = "fLink1";
        //    //Header.Controls.AddAt(2, lit);
             
        //}
        //private string ResolveHeaderUrl(string relativeUrl)
        //{
        //    string url = null;
        //    if (string.IsNullOrEmpty(relativeUrl))
        //    {
        //        url = string.Empty;
        //    }
        //    else if (!relativeUrl.StartsWith("~"))
        //    {
        //        url = relativeUrl;
        //    }
        //    else
        //    {
        //        var basePath = HttpContext.Current.Request.ApplicationPath;
        //        url = basePath + relativeUrl.Substring(1);
        //        url = url.Replace("//", "/");
        //    }
        //    return url;
        //}

        //private string ScriptInclude(string url)
        //{

        //    if (string.IsNullOrEmpty(url))
        //        throw new Exception("路径不存在");

        //    string path = ResolveHeaderUrl(url);
        //    return string.Format("\r\n<script src='{0}' type='text/javascript'></script>", path);
        //}

        //private string cssInclude(string url)
        //{

        //    if (string.IsNullOrEmpty(url))
        //        throw new Exception("路径不存在");

        //    string path = ResolveHeaderUrl(url);
        //    return string.Format("\r\n<link href='{0}' rel='stylesheet'  media='all' type='text/css'/>", path);
        //}

        #endregion






    }
}